import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * la Vista Previa es en particualar importante pues apartir esta clase se 
 * crean los demas objetos como Tags(los que se pondran en el espacio de Tags), 
 * Hoja(En la que se van a arrastrar todo los tags), Revisión(la evaluacion total),y la ayuda 
 * o solucion.
 * @author (your name) 
 * @version (a version number or a date)
 */
public class VistaPrevia extends Actor
{
    private World world;
    private HtmlWorld hW;
    private boolean avanzo = true;
    int nivel = 1;
    
    /**
     * Constructor de Vista Previa
     */
    public VistaPrevia(HtmlWorld w,String rutaBg)
    {
       setImage(rutaBg);
       hW = w;        
        
    }

    /**
     * Act - do whatever the VistaPrevia wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        world = super.getWorld();      
        nivel = hW.dameNivel();
        if(avanzo)
        {
            switch(nivel)
            {
                case 1:
                    world.addObject(new texto(),  673,91); 
                    world.addObject(new headIni(),630,135);
                    world.addObject(new headFin(),630,402);
                    world.addObject(new htmlIni(),705,342);
                    world.addObject(new htmlFin(),712,235);
                    world.addObject(new bodyIni(),635,297);
                    world.addObject(new bodyFin(),678,190);
                    world.addObject(new br(),680,457);
                    actualizarListaDeHoja(nivel);                    
                    avanzo = false;
                    break;
                case 2:  
                    world.addObject(new olFin(),672,87);
                    world.addObject(new li3(),672,115);
                    world.addObject(new bodyFin(),650,147);
                    world.addObject(new li1(),683,197);
                    world.addObject(new olIni(),617,238);
                    world.addObject(new br(),702,252);
                    world.addObject(new h1(),672,289);
                    world.addObject(new bodyIni(),708,331);
                    world.addObject(new texto(),676,379);
                    world.addObject(new li2(),665,425);
                    world.addObject(new img(),671,462);
                    actualizarListaDeHoja(nivel);
                    avanzo = false;
                break;
                case 3:
                    setImage("vistaPrevia3.jpg");
                    world.addObject(new input2(),677,85);
                    world.addObject(new table(),673,152);
                    world.addObject(new input3(),701,215);
                    world.addObject(new formFin(),619,263);
                    world.addObject(new li3(),678,302);
                    world.addObject(new input1(),700,341);
                    world.addObject(new input4(),680,396);
                    world.addObject(new formIni(),682,446);
                    world.addObject(new h1(),677,485);
                    actualizarListaDeHoja(nivel);
                    avanzo = false;
                break;
                case 4:
                    world.addObject(new divIni(),674,104);
                    world.addObject(new formFin(),631,150);
                    world.addObject(new divFin(),711,180);
                    world.addObject(new option3(),677,214);
                    world.addObject(new selectIni(),697,253);
                    world.addObject(new option1(),674,296);
                    world.addObject(new span(),677,364);
                    world.addObject(new selectFin(),689,424);
                    world.addObject(new option2(),672,465);
                    actualizarListaDeHoja(nivel);
                    avanzo = false;
                break;
                case 5:
                    world.addObject(new headIni(),630,135);
                    world.addObject(new headFin(),630,402);
                    world.addObject(new htmlIni(),705,342);
                    world.addObject(new htmlFin(),712,235);
                    world.addObject(new bodyIni(),635,297);
                    world.addObject(new bodyFin(),678,190);
                    world.addObject(new texto(),671,89);
                    world.addObject(new h1(),672,160);
                    world.addObject(new input1(),690,263);
                    world.addObject(new ifram(),676,463);
                    actualizarListaDeHoja(nivel);
                    avanzo = false;
                break;
            }
        }
    } 
    
    public void actualizarListaDeHoja(int n)
    {
        switch(n)
        {
            case 1:
                hW.meteTagsEnListaHoja("htmlIni");
                hW.meteTagsEnListaHoja("htmlFin");
                hW.meteTagsEnListaHoja("headIni");
                hW.meteTagsEnListaHoja("headFin");
                hW.meteTagsEnListaHoja("bodyIni");
                hW.meteTagsEnListaHoja("bodyFin");
                hW.meteTagsEnListaHoja("texto");
                hW.meteTagsEnListaHoja("br");
            break;
            case 2:
                hW.meteTagsEnListaHoja("olFin");
                hW.meteTagsEnListaHoja("li3");
                hW.meteTagsEnListaHoja("bodyFin");
                hW.meteTagsEnListaHoja("li1");
                hW.meteTagsEnListaHoja("olFin");
                hW.meteTagsEnListaHoja("h1");
                hW.meteTagsEnListaHoja("bodyIni");
                hW.meteTagsEnListaHoja("li2");
                hW.meteTagsEnListaHoja("img");
            break;
            case 3:
                hW.meteTagsEnListaHoja("input2");
                hW.meteTagsEnListaHoja("table");
                hW.meteTagsEnListaHoja("input3");
                hW.meteTagsEnListaHoja("formFin");
                hW.meteTagsEnListaHoja("li3");
                hW.meteTagsEnListaHoja("input1");
                hW.meteTagsEnListaHoja("input4");
                hW.meteTagsEnListaHoja("formIni");
                hW.meteTagsEnListaHoja("h1");
            break;
            case 4:
                hW.meteTagsEnListaHoja("divIni");
                hW.meteTagsEnListaHoja("span");
                hW.meteTagsEnListaHoja("selectIni");
                hW.meteTagsEnListaHoja("option1");
                hW.meteTagsEnListaHoja("option2");
                hW.meteTagsEnListaHoja("option3");
                hW.meteTagsEnListaHoja("selectFin");
                hW.meteTagsEnListaHoja("divFin");
            break;
            case 5:
                hW.meteTagsEnListaHoja("texto");
                hW.meteTagsEnListaHoja("iframe");
            break;
        }
    }
    
    public void avanzo()
    {
        avanzo = true;
    }
    
    
}
